package com.battle.project.order.config;


import com.battle.project.order.properties.RabbitMqProperties;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AmqpConfig {

    @Bean
    public ConnectionFactory connectionFactory(RabbitMqProperties rabbitMqProperties){
        CachingConnectionFactory cachingFactory = new CachingConnectionFactory();
        cachingFactory.setHost(rabbitMqProperties.getHost());
        cachingFactory.setUsername(rabbitMqProperties.getUsername());
        cachingFactory.setPassword(rabbitMqProperties.getPassword());
        cachingFactory.setPort(rabbitMqProperties.getPort());
        cachingFactory.setVirtualHost(rabbitMqProperties.getVirtualHost());
        return cachingFactory;
    }
}
